package study.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import study.dao.entity.MovieUser;
import study.feign.UserFeignClient;

@RestController
public class MovieUserController {
	
	@Autowired
	UserFeignClient userFeignClient;
	
	@GetMapping("/feign/{id}")
	public MovieUser selectById(@PathVariable("id") int id) {
		try {
			MovieUser movieUser =  userFeignClient.selectById(id);
			return movieUser;
		} catch (Exception e) {
			System.out.println("#######" + e.toString());
			return null;
		}
	}
	

	/*
		http://localhost:8084/user?id=1&name=sunxj
	 */
	@GetMapping("/user")
	public MovieUser postUser(MovieUser user) {

		try {
			MovieUser user1 = userFeignClient.postUser(user);
			System.out.println("movie-feign: " + user1);
			return user1;
		} catch (Exception e) {
			System.out.println("##########"+ e.toString());
			return null;
		}
	}

}
